Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added sequences support on pyopendds [#18] #20

Closed
wants to merge 3 commits into from

Conversation

Sdpierret
Copy link

This PR add sequences support to pyopendds.

depends #19

Sdpierret added 2 commits May 18, 2021 14:07
Add basic support for publisher

know issue : Segfault after write() call

Signed-off-by: David Pierret <[email protected]>
manage sequences as list
@iguessthislldo iguessthislldo linked an issue Jun 7, 2021 that may be closed by this pull request
Copy link
Member

@iguessthislldo iguessthislldo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a partial review. I still need to review the changes in itl2py and _pyopendds.cpp and look into the issue below. It's getting late for me and I'd like to give you at least some feedback since I've taken so long to review what you've been doing.

The issue I mentioned is I'm getting a segfault as Python is exiting when I try to run the test on my laptop. That is might not be your fault because it's something I once thought might happen when the Python objects are being destroyed, but I'm still looking into it. However before the segfault is happening I can see it's printing out the message, so it's exciting to see that part works!

pyopendds/DataWriter.py Outdated Show resolved Hide resolved
@@ -19,12 +20,13 @@ def init_opendds(*args,
verbose). It is printed to stdout.
'''

args = list(args)
args = list(sys.argv[1:])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a problem with it being possible, but this isn't opt-in anymore like it is in a C++ OpenDDS application, where you have to explicitly give TheParticipantFactoryWithArgs the program arguments. What do you think about making this conditional on keyword argument like from_argv?

pyopendds/init_opendds.py Outdated Show resolved Hide resolved
pyopendds/dev/include/pyopendds/user.hpp Outdated Show resolved Hide resolved
pyopendds/dev/include/pyopendds/user.hpp Outdated Show resolved Hide resolved
publisher = domain.create_publisher()
writer = publisher.create_datawriter(topic)

# Wait for Publisher to Connect
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Wait for Publisher to Connect
# Wait for Subscriber to Connect

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

pyopendds/dev/include/pyopendds/user.hpp Outdated Show resolved Hide resolved
{
// TODO: Encode or Throw Unicode Error
PyObject* repr = PyObject_Repr(py);
PyObject* str = PyUnicode_AsEncodedString(repr, "utf-8", "~E~");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itl2py could set an encoding other than UTF-8. Also this also needs to throw if it failed.

Suggested change
PyObject* str = PyUnicode_AsEncodedString(repr, "utf-8", "~E~");
PyObject* str = PyUnicode_AsEncodedString(repr, encoding, "~E~");
if (!str) throw Exception();

Also what's "~E~" do? I don't see it in the documentation for this function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, "E" is the default string in case of error. replaced by NULL

Comment on lines +260 to +265
// Wait for samples to be acknowledged
DDS::Duration_t timeout = { 30, 0 };
if (writer_impl->wait_for_acknowledgments(timeout) != DDS::RETCODE_OK) {
throw Exception(
"wait_for_acknowledgments error : ", Errors::PyOpenDDS_Error());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a separate operation like it is in OpenDDS, because this could be a lengthy process depending on how much stuff is being sent and to how many peers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, it's needed as a separate function on our application too.

PyObject* write(PyObject* pywriter, PyObject* pysample)
{
DDS::DataWriter* writer = get_capsule<DDS::DataWriter>(pywriter);
if (!writer) PyErr_SetString(PyExc_Exception, "writer is a NULL pointer");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!writer) PyErr_SetString(PyExc_Exception, "writer is a NULL pointer");
if (!writer) throw Exception();

So PyErr_SetString doesn't stop this function from running. All it does is set up an exception that the interrupter will throw when it has the chance. Also get_capsule is already setting PyErr_SetString, all we would have to do here is to stop running this function, which is the purpose of throwing Exception() (with no arguments).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Signed-off-by: David Pierret <[email protected]>
@iguessthislldo
Copy link
Member

Closing in favor of #30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants